package com.notes.designpattern.chain.handler;

import com.alibaba.fastjson.JSON;
import com.notes.designpattern.chain.BusinHandler;
import com.notes.designpattern.chain.BusinHandlerChain;
import com.notes.designpattern.chain.domain.*;

/**
 * @author
 * @Describe 功能描述
 * @date
 */
public class BusinThreeHandler implements BusinHandler<BusinThreeReq, BusinThreeBO, BusinThreeResp> {

    String businName;
    public BusinThreeHandler(String businName) {
        this.businName = businName;
    }

    @Override
    public BusinThreeResp process(BusinThreeReq req, BusinThreeBO businThreeBaseBO, BusinHandlerChain businHandlerChain) {
        System.out.println("开始执行" + this.businName + "入参: " + JSON.toJSONString(req));
        BusinThreeResp businThreeResp = new BusinThreeResp();
        if (this.businName.equals("BusinThreeHandler")) {
            businThreeResp.setBusinResp("BusinThreeHandler");
            businThreeResp.setBusinTwoResp(req.getBusinTwoBaseResp());
            System.out.println("开始执行" + this.businName + "成功，出参: " + JSON.toJSONString(businThreeResp));
            businHandlerChain.process(new BaseReq(), new BaseBO(), businHandlerChain);
            return businThreeResp;
        }
        businThreeResp.setErrorNo(-1);
        System.out.println("开始执行" + this.businName + "失败，出参: " + JSON.toJSONString(businThreeResp));
        return businThreeResp;
    }
}
